package com.yida.wy.common.service.impl;

import com.yida.common.core.utils.DateUtils;
import com.yida.common.security.utils.SecurityUtils;
import com.yida.wy.common.domain.WyBaseHouse;
import com.yida.wy.common.domain.dto.WyBaseHouseDTO;
import com.yida.wy.common.domain.dto.WyBaseHouseSstatisticsDTO;
import com.yida.wy.common.domain.dto.WyBaseOwnerListDTO;
import com.yida.wy.common.domain.request.WyBaseHouseRequest;
import com.yida.wy.common.domain.request.WyBaseOwnerQueryRequest;
import com.yida.wy.common.mapper.WyBaseHouseMapper;
import com.yida.wy.common.service.IWyBaseHouseService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 基础数据（房屋）Service业务层处理
 *
 * @author lqq
 * @date 2022-11-14
 */
@Service
public class WyBaseHouseServiceImpl extends BasicServiceImpl<WyBaseHouseMapper, WyBaseHouse> implements IWyBaseHouseService {

    @Resource
    private WyBaseHouseMapper houseMapper;

    /**
     * 查询基础数据（房屋）
     *
     * @param id 基础数据（房屋）主键
     * @return 基础数据（房屋）
     */
    @Override
    public WyBaseHouse selectGwjBaseHouseByGwjBaseHouseId(Long id) {
        return houseMapper.selectGwjBaseHouseByGwjBaseHouseId(id);
    }

    /**
     * 查询基础数据（房屋）列表
     *
     * @param house 基础数据（房屋）
     * @return 基础数据（房屋）
     */
    @Override
    public List<WyBaseHouse> selectGwjBaseHouseList(WyBaseHouse house) {
        return houseMapper.selectGwjBaseHouseList(house);
    }

    /**
     * 根据楼栋标识码和地区ID查询房屋集合
     *
     * @param buildCodes 楼栋标识码集合
     * @param areaId     地区ID
     * @return /
     */
    @Override
    public List<WyBaseHouse> selectGwjBaseListByBuildCodesAndAreaId(String[] buildCodes, Long areaId) {
        return houseMapper.selectGwjBaseListByBuildCodesAndAreaId(buildCodes, areaId);
    }

    /**
     * 修改基础数据（房屋）
     *
     * @param house 基础数据（房屋）
     * @return 结果
     */
    @Override
    public int updateGwjBaseHouse(WyBaseHouse house) {
        house.setUpdateBy(SecurityUtils.getLoginUser().getSysUser().getRealName());
        house.setUpdateTime(DateUtils.getNowDate());
        return houseMapper.updateGwjBaseHouse(house);
    }

    /************************* 新功能保留区 ************************************/

    /**
     * 根据项目编号查询基础数据（房屋）列表
     *
     * @param houseRequest 项目编号
     */
    @Override
    public List<WyBaseHouseDTO> queryGwjBaseHouseListByParam(WyBaseHouseRequest houseRequest) {
        return houseMapper.queryGwjBaseHouseListByParam(houseRequest);
    }

    /**
     * 根据参数查询房屋统计数据
     *
     * @param houseRequest
     * @return
     */
    @Override
    public WyBaseHouseSstatisticsDTO queryGwjBaseHouseStatisticsByParam(WyBaseHouseRequest houseRequest) {
        return houseMapper.queryGwjBaseHouseStatisticsByParam(houseRequest);
    }

    @Override
    public WyBaseHouse selectGwjBaseHouseByLocation(String location, String buildCode) {
        return houseMapper.selectGwjBaseHouseByLocation(location, buildCode);
    }

    @Override
    public int insertImportGwjBaseHouse(List<WyBaseHouse> houses) {
        return houseMapper.insertImportGwjBaseHouse(houses);
    }

    @Override
    public int updateImportGwjBaseHouse(List<WyBaseHouse> houses) {
        return houseMapper.updateImportGwjBaseHouse(houses);
    }

    /**
     * 根据小区ID查询业主信息（含房屋数据）
     *
     * @param request 请求
     * @return /
     */
    @Override
    public List<WyBaseOwnerListDTO> selectGwjBaseOwnerDtoListByCommunityId(WyBaseOwnerQueryRequest request) {
        return houseMapper.selectGwjBaseOwnerDtoListByCommunityId(request);
    }
}
